<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>路由的嵌套</title>
	</head>
	<body>
		<div id="ap">
			<router-link to="/car">汽车</router-link>
			<router-link to="/truck">卡车</router-link>
			<!-- 路由占位A -->
			<router-view></router-view>
		</div>
		
		<template id="carTem">
			<div>
				<h2>汽车信息</h2>
				<router-link to="/BMW">BMW</router-link>
				<router-link to="/BYD">BYD</router-link>
				<!-- 路由占位B -->
				<router-view></router-view>
			</div>
		</template>
		<template id="truckTem">
			<div>
				<h2>卡车信息</h2>
			</div>
		</template>
		<template id="BMW">
			<div>
				<h2>宝马930</h2>
			</div>
		</template>
		<template id="BYD">
			<div>
				<h2>比亚迪-秦</h2>
			</div>
		</template>
		
		<script src="../js/vue.js"></script>
		<script src="../js/vue-router.js"></script>
		<script>
			let carCom = {
				template : "#carTem"
				}
			let truckCom = {
				template : "#truckTem"
				}
			let BMWCom = {
				template : "#BMW"
				}
			let BYDCom = {
				template : "#BYD"
				}	
				/*路由展现问题说明:
				 如果需要进行路由嵌套,需要children
				 子级路由会在当前占位符中进行展现
				 如果不加入children,那么会抢占父级的占位符
				 */
			let vueRouter = new VueRouter({
				routes: [
					/* {path:"/", redirect:"/truck"}, */
					{path:"/car", component: carCom, 
					
					0children:[
						{path:"/BYD", component: BYDCom},
						{path:"/BMW", component: BMWCom}
					]},
					{path:"/truck", component: truckCom}
				]
			})
			/* vue对象,router挂载 */
			const app =new Vue({
				el: "#ap",
				router: vueRouter
				
			})
		</script>
			
	</body>
</html>
